<?
require_once("class_GenericRowSerial.php");

/********************************************************************************************************/
/* This class represents one row from any table which hase non composit not autoincremented PRIMARY KEY */
/********************************************************************************************************/

class FunctionName extends GenericRowSerial {

    public function FunctionName($id=false) {
	parent::__construct('function_name','id',$id);
    }

    public function get_stat($time_id,$prod_sql) {
	$prod_sql->select_c("
SELECT
COALESCE(pg_stat_get_function_calls(oid),0) AS func_calls,
COALESCE((pg_stat_get_function_time(oid)),0) AS total_time,
COALESCE((pg_stat_get_function_self_time(oid)),0) AS self_time
FROM pg_proc p
WHERE oid=".$this->get_field('pro_oid'));
	$func_stat=$prod_sql->get_row_hash();
	$this->sql->non_select_c("INSERT INTO function_stat VALUES ("
	.$this->id.","
	.$time_id.","
	.$func_stat['func_calls'].","
	.$func_stat['total_time'].","
	.$func_stat['self_time'].")");
    }

    public function __toString() {
	return $this->get_field('func_name');
    }
}

?>
